package main.inquiry;

import base.BaseCanvasWindow;

import dao.MakeupScoreCanvasDao;
import model.MakeupScore;

import java.awt.*;
import java.util.List;

public class MakeupScoreCanvas extends BaseCanvasWindow {

    @Override
    protected String setCanvasTitle() {
        return "补考成绩单";
    }

    @Override
    protected Canvas setCanvasContent() {
        return new MakeupScoreArea();
    }

    class MakeupScoreArea extends Canvas {
        public void paint(Graphics g) {
            g.setColor(Color.BLACK);
            g.drawString("以下为补考成绩单", 80, 20);
            g.drawString("学号", 10, 40);
            g.drawString("姓名", 80, 40);
            g.drawString("补考课程", 130, 40);
            g.drawString("补考成绩", 200, 40);

            try {
                List<MakeupScore> list = MakeupScoreCanvasDao.getMakeupScores();
                int length = list.size();

                for (int i = 0; i < length; i++) {
                    MakeupScore makeupScore = list.get(i);
                    String sno = makeupScore.getSno();
                    String sname = makeupScore.getSname();
                    String cname = makeupScore.getCname();
                    String score = makeupScore.getMakeupScore() + "";

                    g.drawString(sno, 10, 60 + 20 * i);
                    g.drawString(sname, 80, 60 + 20 * i);
                    g.drawString(cname, 130, 60 + 20 * i);
                    g.drawString(score, 220, 60 + 20 * i);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
